package Servelet;

import com.sun.javaws.IconUtil;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.nio.charset.Charset;

/***
 *@title $NAME
 *@description <TODO description class purpose>
 *@author Tang'ya'kang
 *@VERSION 1.0.0
 *@CREATE 2023/4/27 20:34
 **/
public class Response extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// 方案1=> response.setCharacterEncoding("UTF-8");
//        response.setHeader("Content-Type","text/html; charset=UTF-8");
//        方案2：
        response.setContentType("text/html;charset=UTF-8");
        System.out.println(response.getCharacterEncoding());
        Writer writer=response.getWriter();
        writer.write("Hello 汤亚康");
    }
}
